package com.woniu.service.healthSystem.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.mapper.healthSystem.RoleMapper;
import com.woniu.model.healthSystem.entity.Role;
import com.woniu.model.healthSystem.vo.PageVo;
import com.woniu.service.healthSystem.IRoleService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author gb
 * @since 2023-10-19
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Override
    public PageVo findAll(Integer pageNum, Integer pageSize, String name) {
        LambdaQueryWrapper<Role> wrapper = Wrappers.lambdaQuery(Role.class);
        wrapper.like(StringUtils.hasText(name),Role::getName,name);
        Page<Role> page = baseMapper.selectPage(new Page<>(pageNum, pageSize), wrapper);
        return new PageVo<>(page.getRecords(),page.getTotal());
    }
}
